public class Solution03 {
	public int findBottomLeftValue(TreeNode root) {
		Queue<TreeNode> queue = new LinkedList<>();
		queue.offer(root);
		int bottomLeftVal = root.val;
		while(!queue.isEmpty()){
			//获取当前队列长度
			int curQueueLen = queue.size(); 
			//每次重新开始for循环时,队列里存储的所有元素即为该层的所有元素，层次遍历
			for(int i = 0; i < curQueueLen; i++){
				TreeNode curNode = queue.poll();
				if(i == 0){
					bottomLeftVal =  curNode.val;
				}
				if(curNode.left != null){
					queue.offer(curNode.left);
				}
				if(curNode.right != null){
					queue.offer(curNode.right);
				}
			}
		}
		return bottomLeftVal;
	}
}
